package com.yunji.app.base;

import com.yunji.base.business.StaffBusiness;
import com.yunji.base.vo.StaffVO;
import com.yunji.common.base.BaseController;
import com.yunji.common.base.response.Response;
import com.yunji.common.base.response.ResponseHelper;
import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.system.context.SystemContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Project: yunji-coffee
 * @Package com.yunji.app.user
 * @FileName GatewayStaffController.java
 * @Copyright Copyright © 2024 云集互联. All Rights Reserved
 * @Company com
 * @Version 1.0
 * @Since JDK1.8.0_201
 * @CreateTime 2024-06-10 22:21:45
 * @Description 移动端-员工操作交互
 * @Modification History
 * Author					History Time			Version			Description
 * -------------------------------------------------------------------------------
 * HuaAo0803@163.com	2024-06-10 22:21:45		1.0				1.0
 */
@RestController
@Api(tags = "移动端-员工操作")
@RequestMapping("/gateway/staff")
public class GateWayStaffController extends BaseController {
    @Resource
    StaffBusiness business;

    @ApiOperation("获取当前登录员工的信息")
    @GetMapping("/getStaffInfo")
    public Response<StaffVO> getStaffInfo() {
        return ResponseHelper.success(business.selectStaffById(SystemContext.getUser().getUserId()));
    }

    @ApiOperation("人工审核")
    @GetMapping("/manualCheck")
    public Response<String> manualCheck(@RequestParam("check") Integer check) {
        redisCache.set("AUDIT:", check == 1);
        return ResponseHelper.success("操作成功");
    }

    @ApiOperation("取审核结果")
    @GetMapping("getCheckResult")
    public Response<Boolean> getCheckResult() {
        Boolean result = redisCache.get("AUDIT:");
        Assert.isTrue(BeanUtils.isNotNull(result), "取出失败");
        return ResponseHelper.success(result);
    }

}